package com.shopyourstyle.activities;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.RadioGroup;
import android.widget.TextView;
import android.widget.Toast;

import com.shopyourstyle.R;

public class RegisterActivity extends Activity {
	private String MSG_TAG = "RegisterActivity";
	private String username = null;
	private String password = null;
	private String name = null;
	private String email = null;
	private int gender = 0;
	private int age = 0;
	private TextView passConfirm = null;
	private EditText usernameEdt = null;
	private EditText passwordEdt = null;
	private EditText nameEdt = null;
	private EditText emailEdt = null;
	private RadioGroup genderGrp = null;
	private RadioGroup ageGrp = null;
	private Button nextBtn = null;
	
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.register);
        Log.d(MSG_TAG, "OnCreate()");
        findView();
        setListener();
    }
    
    private void findView() {
    	passConfirm = (TextView)findViewById(R.id.register_password_confirm);
    	nextBtn = (Button)findViewById(R.id.register_next);
    	usernameEdt = (EditText)findViewById(R.id.register_username);
    	passwordEdt = (EditText)findViewById(R.id.register_password);
    	nameEdt = (EditText)findViewById(R.id.register_name);
    	emailEdt = (EditText)findViewById(R.id.register_email);
    	genderGrp = (RadioGroup)findViewById(R.id.register_gender);
    	ageGrp = (RadioGroup)findViewById(R.id.register_age);
    }
	private void setListener() {
		nextBtn.setOnClickListener(nextBtnLs);
	}
	
	private Button.OnClickListener nextBtnLs=new Button.OnClickListener(){
		@Override
		public void onClick(View v) {
			username = usernameEdt.getText().toString();
			password = passwordEdt.getText().toString();
			name = nameEdt.getText().toString();
			email = emailEdt.getText().toString();
			gender = genderGrp.getCheckedRadioButtonId();
			age = ageGrp.getCheckedRadioButtonId();
			
			if(gender == R.id.register_radiobutton_female){
				gender = 0;
			}else{
				gender = 1;
			}
			
			if(age == R.id.register_radiobutton_18){
				age = 18;
			}else if(age == R.id.register_radiobutton_25){
				age = 25;
			}else if(age == R.id.register_radiobutton_35){
				age = 35;
			}else{
				age = 45;
			}
			
			if(checkData(username, password, name, email, gender, age)){
				//Toast.makeText(getApplication(), "��U���\�A�w��!", Toast.LENGTH_SHORT).show();
				finish();
			}
		}

	};
	
	private boolean checkData(String username, String password, String name, String email, int gender, int age){
		// TODO Auto-generated method stub
		return true;
	}
}